const { filterByKeyword } = require('../../../common/utils/searchUtil');
const pluginWarper = require('../../../core/warper/pluginWarper');
const { doOrderPlugin } = require('./doOrderPlugin')

exports.doSearchByFile = async function (request) {
    const input = request.input
    let plugins = []

    if (input.indexOf("plugin.json") > 0) {
        const plugin = pluginWarper.functionPluginWarper("打包插件", "将插件打包成asar离线插件包", null, "createPackage")
        plugins.push(plugin)
    } else if (input.indexOf("plugin.asar") > 0) {
        const plugin = pluginWarper.functionPluginWarper("离线安装插件", "本地离线安装插件", null, "setupPackage")
        plugins.push(plugin)
    }
    return {
        preSearch: null,
        resultList: doOrderAndFilterPLugin(plugins, request)
    }

}



function doOrderAndFilterPLugin(plugins, request) {
    plugins = filterByKeyword(plugins, null)
    plugins = doOrderPlugin(plugins)
    return plugins
}
